Skip to content

Support memset on structs - #634

Merged
Firestar99 merged 1 commit into
Rust-GPU:mainfrom
nazar-pc:fix-memset
Aug 4, 2026
Merged

Support memset on structs#634
Firestar99 merged 1 commit into
Rust-GPU:mainfrom
nazar-pc:fix-memset

Conversation

@nazar-pc

@nazar-pc nazar-pc commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

I decided to ask Claude to fix #312 and it turned out fairly simple.

Here is LLM-generated description of changes:

Implement memset_const_pattern and memset_dynamic_pattern for SpirvType::Adt by recursively building a fill pattern per field and composing them into a struct constant/composite, instead of hitting fatal!("memset on structs not implemented yet").

This unblocks crates that zero-init or byte-fill whole structs (e.g. core::mem::zeroed::<T>() on a struct type), such as the blake3 crate hitting this on self.buf = [0; BLOCK_LEN].

With this change I can add blake3 crate to dependencies and things continue to compile without issues, while previously I was hitting an error like this:

  error: memset on structs not implemented yet
     --> /home/nazar-pc/.cargo/git/checkouts/blake3-697b574540d368df/c7f0d21/src/lib.rs:550:17
      |
  550 |                 self.buf = [0; BLOCK_LEN];
      |                 ^^^^^^^^^^^^^^^^^^^^^^^^^

Fixes #312, closes #328

@nazar-pc nazar-pc mentioned this pull request Aug 4, 2026

@Firestar99 Firestar99 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@Firestar99
Firestar99 added this pull request to the merge queue Aug 4, 2026
Merged via the queue into Rust-GPU:main with commit e3a26ef Aug 4, 2026
23 checks passed
@nazar-pc
nazar-pc deleted the fix-memset branch August 4, 2026 13:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unclear ICE

2 participants